import { configure, addDecorator, addParameters } from '@storybook/react'
import { withInfo } from '@storybook/addon-info'
import '../src/styles/index.scss'
import React from 'react'

const wrapperStyle: React.CSSProperties = {
  padding: '20px 40px',
}
const CenterDecorator = (storyFn: any) => (
  <div style={wrapperStyle}>
    {/* <h3>组件演示</h3> */}
    {storyFn()}
  </div>
)
const loaderFn = () => {
  const allExports = [require('../src/welcome.stories.tsx')]
  const req = require.context('../src/components', true, /\.stories\.tsx$/)
  req.keys().forEach(fname => allExports.push(req(fname)))
  return allExports
}

addDecorator(CenterDecorator)
addDecorator(withInfo as any)
addParameters({
  info: {
    inline: true,
    header: false,
  },
})

// automatically import all files ending in *.stories.tsx
configure(loaderFn, module)
